package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/api/v1")
public class BehaviorController {
   @Autowired
    ApReadBehaviorService apReadBehaviorService;
   @Autowired
    ApLikesBehaviorService apLikesBehaviorService;
   @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;
   @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;
   @Autowired
   ApArticleBehaviorService apArticleBehaviorService;
    //阅读行为
    @PostMapping("/read_behavior")
    public ResponseResult read(@RequestBody @Valid ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }

    //点赞行为
    @PostMapping("/likes_behavior")
    public ResponseResult likes(@RequestBody @Valid LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    //不喜欢行为
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLike(@RequestBody @Valid UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }
//收藏行为
    @PostMapping("/collection_behavior")
    public ResponseResult collection(@RequestBody @Valid CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }
    //文章行为
    @PostMapping("/article/load_article_behavior")
    public ResponseResult arctleBehavior(@RequestBody @Valid ArticleBehaviorDTO dto) {
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }
}
